// pages/mine/presidentWelfare/presidentWelfare.js
const app=getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    company:[],
  },
  //剩余发布次数
  residue_time() {
    wx.request({
      url: app.globalData.url + 'api/recruit/limit/number',
      data: {
        token: app.globalData.token,
      },
      method: 'POST',
      success: (e) => {
        // console.log(e)
        let last_time = e.data.data.is_send;
        this.setData({
          last_time: last_time,
        })
      },
    })
  },
  //去发布职位
  go_postJob(){
    let that=this;
    this.residue_time();
    if (this.data.is_perfect == 1) {
      if (this.data.last_time <= 0) {
        wx.showModal({
          content: '职位发布数量已用完,暂不能发布新的职位',
          showCancel: false,
          confirmText: '好的',
          confirmColor: '#d0a76c',
        })
      } else {
        wx.navigateTo({
          url: '../../recruit/postJob/postJob?welfare=true',
        })
      }
      // wx.navigateTo({
      //   url: '../../recruit/postJob/postJob?welfare=true',
      // })
    }else{
      wx.showModal({
        content: '请先完善公司信息',
        showCancel: true,
        cancelText: '取消',
        cancelColor: '#333',
        confirmText: '好的',
        confirmColor: '#d0a76c',
        success: function(e) {
          if (e.confirm){
            wx.navigateTo({
              url: '../../mine/CompanyBasis/CompanyBasis?ProcessJudge=false',
            })
          }
        },
      })
     
    }
    
  },
  //去VIP
  go_vip(){
    wx.navigateTo({
      url: '../vip/index',
    })
  },
  //获取次数信息
  getTimeinfo(){
    wx.request({
      url: app.globalData.url + 'api/common/register/info',
      data: {
        token: app.globalData.token,
      },
      method: 'POST',
      success: (e)=>{
        console.log(e)
        let info = e.data.data;
        this.setData({
          info: info,
        })
      },
    })
  },
  //点击公司认证
  go_approve(){
    let that=this;
    wx.showToast({
      title: '请下载直播之家App~',
      icon: 'none',
    })
  },
  //获得存在公司信息
  get_iscompany(){
    let that=this;
    wx.request({
      url: app.globalData.url + 'api/guild/company/add',
      data: {
        token:app.globalData.token,
        type:2,
      },
      method: 'POST',
      success: function(e) {
        // console.log(e.data.data.company)
        let company = e.data.data.company;
        that.setData({
          company: company,
        })
      },

    })
  },
  //是否认证
  get_approve(){
    let that=this;
    wx.request({
      url: app.globalData.url + 'api/legal/is_face',
      data: {
        token:app.globalData.token,
      },
      method: 'POST',
      success: function(e) {
        console.log(e)
        let is_company = e.data.data.is_company;
        that.setData({
          is_company: is_company,
        })
      },
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.get_iscompany();
    this.get_approve();
    this.getTimeinfo();
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})